{% extends 'TopxiaWebBundle:Course:normal-layout.html.twig' %}

{% set tab = 'thread' %}

{% set post = post|default(null) %}

{% block title %}{% if post %}{{'编辑帖子'|trans}}{% else %}{{'回复帖子'|trans}}{% endif %} - {{ parent() }}{% endblock %}

{% set script_controller = 'course/thread-post-form' %}

{% block course_main %}

<ul class="breadcrumb">
  <li><a href="{{ path('course_threads', {id:course.id}) }}">{{'讨论区'|trans}}</a></li>
  <li><a href="{{ path('course_thread_show', {courseId:thread.courseId, threadId:thread.id}) }}">{{ thread.title|plain_text(10) }}</a></li>
  <li class="active">{{'编辑帖子'|trans}}</li>
</ul>

<form id="thread-post-form" method="post"
  {% if post %}
    action="{{ path('course_thread_post_edit', {courseId:course.id, threadId:post.threadId, id:post.id}) }}"
  {% else %}
    action="{{ path('course_thread_post', {courseId:course.id, id:post.id}) }}"
  {% endif %}
  >
  <div class="form-group">
    <div class="controls">
      {{
        form_widget(
          form.content, {
            attr:{
              class:'form-control',
              rows:15,
              'data-display':'内容'|trans,
              'data-image-upload-url': path(
                'editor_upload', {
                  token:upload_token('course')
                }
              ),
              'data-image-download-url': path(
                'editor_download', {
                  token:upload_token('course')
                }
              )
            }
          }
        )
      }}
    </div>
  </div>
  <div class="form-group">
    <div class="controls clearfix">
      {{ form_rest(form) }}
      <button type="submit" class="btn btn-primary pull-right">{{'发表'|trans}}</button>
      <a href="{{ path('course_threads', {id:course.id}) }}" class="btn btn-link pull-right">{{'取消'|trans}}</a>
    </div>
  </div>

  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>

{% endblock %}
